import requests from "./request";
import mockRequests from "./mockRequest";

// 获取三级分类数据
export const reqCategoryList = () => {
    return requests({
        url: '/product/getBaseCategoryList',
        method: 'GET'
    })
}

// 获取轮播图数据
export const reqBannerList = () => {
    return mockRequests({
        url: '/banner',
        method: 'GET'
    })
}

// 获取楼层数据
export const reqFloorList = () => {
    return mockRequests({
        url: '/floor',
        method: 'GET'
    })
}

export const reqGetSearchInfo = (data) => {
    return requests({
        url: '/list',
        method: 'POST',
        data
    })
}

// 获取商品详情
export const reqGetGoodsInfo = (skuid) => {
    return requests({
        url: `/item/${skuid}`,
        method: 'GET',
    })
}

// 添加购物车
export const reqAddOrUpdateShopCart = (skuid, skuNum) => {
    return requests({
        url: `/cart/addToCart/${skuid}/${skuNum}`,
        method: 'POST',
    })
}

// 获取购物车列表
export const reqShopCartList = () => {
    return requests({
        url: `/cart/cartList`,
        method: 'GET',
    })
}

// 删除购物车产品
export const reqDeleteShopCart = (skuId) => {
    return requests({
        url: `/cart/deleteCart/${skuId}`,
        method: 'DELETE',
    })
}

// 修改购物车选中
export const reqUpdateShopCart = (skuId, isChecked) => {
    return requests({
        url: `/cart/checkCart/${skuId}/${isChecked}`,
        method: 'GET',
    })
}

// 获取验证码
export const reqGetCode = (phone) => {
    return requests({
        url: `/user/passport/sendCode/${phone}`,
        method: 'GET',
    })
}

// 注册账号
export const reqRegister = (data) => {
    return requests({
        url: `/user/passport/register`,
        data,
        method: 'POST',
    })
}

// 用户登录
export const reqLogin = (data) => {
    return requests({
        url: `/user/passport/login`,
        data,
        method: 'POST',
    })
}

// 获取用户信息
export const reqGetUserInfo = () => {
    return requests({
        url: `/user/passport/auth/getUserInfo`,
        method: 'GET'
    })
}

// 退出登录
export const reqLogout = (data) => {
    return requests({
        url: `/user/passport/logout`,
        method: 'GET',
    })
}

// 获取用户地址
export const reqUserAddress = () => {
    return requests({
        url: `/user/userAddress/auth/findUserAddressList`,
        method: 'GET',
    })
}

// 获取购物清单
export const reqUserOrderList = () => {
    return requests({
        url: `/order/auth/trade`,
        method: 'GET',
    })
}

// 提交订单
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({
        url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
        data,
        method: 'POST',
    })
}

// 获取支付信息
export const reqPayInfo = (orderId) => {
    return requests({
        url: `/payment/weixin/createNative/${orderId}`,
        method: 'GET',
    })
}
// 获取支付状态
export const reqPayStatus = (orderId) => {
    return requests({
        url: `/payment/weixin/queryPayStatus/${orderId}`,
        method: 'GET',
    })
}

// 获取个人中心数据
export const reqUserData = (page, limit) => {
    return requests({
        url: `/order/auth/${page}/${limit}`,
        method: 'GET',
    })
}